# -*- python -*-
# ex: set syntax=python:

# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# See master.experimental/slaves.cfg for documentation.

slaves = [
  {
    'master': 'DartFYI',
    'builder': ['dart2js-linux-debug-checked-host-checked'],
    'hostname': 'vm95-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  # This machine has specialized setup - please don't move the slave without
  # pinging ricow@
  {
    'master': 'DartFYI',
    'builder': ['ft-slave-linux'],
    'hostname': 'vm127-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['dart2js-linux-debug-host-checked'],
    'hostname': 'vm187-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['dart2js-linux-debug-checked',
                'dart2js-chrome-linux',
                'dart2js-linux-debug',],
    'hostname': 'vm118-m3',
    'os': 'linux',
   'version': 'precise',
    'bits': '64',
  },
  # This machine has specialized setup - please don't move the slave without
  # pinging ricow@
  {
    'master': 'DartFYI',
    'builder': ['ft-master'],
    'hostname': 'vm343-m3',
    'os': 'linux',
   'version': 'precise',
    'bits': '64',
  },
  # This machine has specialized setup - please don't move the slave without
  # pinging ricow@
  {
    'master': 'DartFYI',
    'builder': ['dart2js-linux-release-host-checked',
                'dart2js-linux-release-checked-host-checked'],
    'hostname': 'vm159-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['dart2js-linux-release-cps'],
    'hostname': 'vm207-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['dart2js-full-windows-1-6'],
    'hostname': 'vm77-m3',
    'os': 'win',
    'version': 'win7',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['dart2js-chromeOnAndroid-linux'],
    'hostname': 'chromeperf02',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['vm-android-linux',
                'v8-linux-release',
                'dart2js-linux-release',
                'dart2js-linux-release-checked-host-checked-x64',
                'dartium-lucid64-debug-dev',],
    'hostname': 'vm340-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['v8-mac-release'],
    'hostname': 'vm607-m3',
    'os': 'mac',
    'version': '10.7',
    'bits': '64',
  },
  # This machine has specialized setup - please don't move the slave without
  # pinging ricow@
  {
    'master': 'DartFYI',
    'builder': ['ft-slave-mac'],
    'hostname': 'vm680-m3',
    'os': 'mac',
    'version': '10.7',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['v8-win-release'],
    'hostname': 'vm210-m3',
    'os': 'win',
    'version': 'win7',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['dartium-mac-debug'],
    'hostname': 'vm608-m3',
    'os': 'mac',
    'version': '10.7',
    'bits': '64'
  },
  {
    'master': 'DartFYI',
    'builder': ['dartium-lucid64-debug-be'],
    'hostname': 'vm96-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['dartium-lucid64-debug-stable',
                'dartium-lucid64-debug-integration'],
    'hostname': 'vm99-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['dartium-win-debug-be',
                'dartium-win-debug-stable'],
    'hostname': 'vm112-m3',
    'os': 'win',
    'version': 'win7',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['dartium-win-debug-integration',
                'dartium-win-debug-dev'],
    'hostname': 'vm192-m3',
    'os': 'win',
    'version': 'win7',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['dartium-linux-perf-be', 'multivm-linux-perf-be'],
    'hostname': 'build15-a3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['dartium-mac-perf-be', 'multivm-mac-perf-be'],
    'hostname': 'build17-a3',
    'os': 'mac',
    'version': '10.7',
    'bits': '64'
  },
  {
    'master': 'DartFYI',
    'builder': ['dartium-win-perf-be', 'multivm-win-perf-be'],
    'hostname': 'build16-a3',
    'os': 'win',
    'version': 'win7',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['dartium-linux-build-be', 'multivm-linux-build-be'],
    'hostname': 'vm10-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['dartium-mac-build-be'],
    'hostname': 'vm618-m3',
    'os': 'mac',
    'version': '10.7.5',
    'bits': '64'
  },
  {
    'master': 'DartFYI',
    'builder': ['dartium-win-build-be'],
    'hostname': 'vm18-m3',
    'os': 'win',
    'version': 'win7',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['multivm-mac-build-be'],
    'hostname': 'vm676-m3',
    'os': 'mac',
    'version': '10.7.5',
    'bits': '64'
  },
  {
    'master': 'DartFYI',
    'builder': ['multivm-win-build-be'],
    'hostname': 'vm126-m3',
    'os': 'win',
    'version': 'win7',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['vm-mips-release'],
    'hostname': 'build19-a3',
    'os': 'linux',
    'version': 'debian squeeze',
    'bits': 'mips 32',
  },
  {
    'master': 'DartFYI',
    'builder': ['vm-mips-debug'],
    'hostname': 'build20-a3',
    'os': 'linux',
    'version': 'debian squeeze',
    'bits': 'mips 32',
  },
  {
    'master': 'DartFYI',
    'builder': ['dart2js-dump-info'],
    'hostname': 'vm117-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },

]


# This is hack to eliminate the need for sharing code between master and
# clients. These channels are replicated in scripts/factory/dart/channels.py.
channel_postfixes = ['-be', '-dev', '-stable', '-integration']

def valid_for_channel(builder, channel):
  """ Returns true if we have this builder on this specific channel"""
  return channel != '-integration' or ('dartium' in builder and not
                                       'dartium-android-release' in builder)

def is_channel_builder(builder):
  """Returns true if the builder name is already specific to a channel
  (i.e. the builder ends with a channel postfix)."""
  for postfix in channel_postfixes:
    if builder.endswith(postfix):
      return True
  return False

def duplicate_builders_in_slaves(slaves):
  """Traverses a list of slaves and duplicates the builders associated with each
  slave for every channel. The channels have specified the postfix."""
  for slave in slaves:
    all_builders = []
    for builder in slave.get('builder', ()):
      if ('v8' not in builder
          and not is_channel_builder(builder)):
        for channel in channel_postfixes:
          # Some channels don't have all builders
          if valid_for_channel(builder, channel):
            all_builders.append('%s%s' % (builder, channel))
      else:
        all_builders.append(builder)
    slave['builder'] = all_builders
  return slaves

slaves = duplicate_builders_in_slaves(slaves)
